package com.iot.controller;

import com.iot.model.query.MessageQuery;
import com.iot.model.dto.MessageDto;
import com.iot.service.MessageService;
import com.iot.commons.ResponseResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 
 * @author: dh
 * @date: 2024-04-28 16:12:50
 */
@RestController
@RequestMapping("/message")
@RequiredArgsConstructor
public class MessageController {

    private final MessageService messageService;

    /**
     * 分页条件搜索实现
     * @param message
     * @return resultList
     */
    @PostMapping(value = "/getList")
    public ResponseResult getList(@RequestBody MessageQuery message) {
        return  messageService.getList(message);
    }

    /**
     * 回复消息
     * @param message
     * @return
     */
    @PostMapping(value = "/reply")
    public ResponseResult reply(@RequestBody MessageDto message) {
        return messageService.reply(message);
    }

    /**
     * 新增
     * @param message
     * @return
     */
    @PostMapping(value = "/add")
    public ResponseResult add(@RequestBody MessageDto message) {
        return messageService.add(message);
    }


    /**
     * 详情
     * @param message
     * @return
     */
    @PostMapping(value = "/getById")
    public ResponseResult getById(@RequestBody MessageQuery message) {
        return messageService.getById(message);
    }
}
